#include"lockqueue.h"
#include<string>

enum LogLevel
{
    INFO,
    ERROR
};


class Logger
{
public:
    //日志单例
    static Logger& GetInstance();
    //设置日志等级
    void SetLogLevel(LogLevel level);
    //日志写入
    void Log(std::string msg); 
private:
    int _loglevel;
    LockQueue<std::string> _lckque;

    Logger();
    Logger(const Logger& log)=delete;
    Logger(const Logger&& log)=delete;
};



#define LOG_INFO(logmsgformat,...)                  \
    do                                              \
    {                                               \
        Logger& logger = Logger::GetInstance();     \
        logger.SetLogLevel(INFO);                   \
        char c[1024]={0};                           \
        snprintf(c,1024,logmsgformat,##__VA_ARGS__); \
        logger.Log(c);                              \
    }while(0); 


#define LOG_ERR(logmsgformat,...)                   \
    do                                              \
    {                                               \
        Logger& logger = Logger::GetInstance();     \
        logger.SetLogLevel(ERROR);                  \
        char c[1024]={0};                           \
        snprintf(c,1024,logmsgformat,##__VA_ARGS__); \
        logger.Log(c);                              \
    }while(0);